By using this extentions to mod_include, you can make your own function for SSI (Server Side Includes) and you can call your function with SSI directives. This solution is based on mod_so and mod_include. By using DSSI, you can integrate your CGI easily and make your CGI faster than any other CGI accelerator.
By using LoadDSSI directive, you can load your dynamic functions. Later one override earlier ones. It means, you can only call functions of the last one with DSSI directive.
AddType text/html .shtml AddHandler server-parsed .shtml LoadDSSI libexec/dssi_util.so LoadDSSI libexec/dssi.so
<!--#exec func="dssi_function_name dssi_function_arguments"-->dssi_function_arguments should not contain white spaces.
You can write DSSI funtions by using Apache API functions.
temp_cgi.c:
#include <stdio.h>
void main()
{
char *s;
printf("Content-type: text/html\n\n");
printf("<html><body><pre>\n");
s = (char *)getenv("QUERY_STRING");
if(s && *s)
printf("%s\n",s);
s = (char *)getenv("DOCUMENT_ROOT");
if(s && *s)
printf("%s\n",s);
printf("</pre></body></html>");
}
You can simply integrate this CGI to DSSI.
temp_dssi.c:
#include "httpd.h"
#include "http_config.h"
#include "http_request.h"
#include "http_core.h"
#include "http_protocol.h"
#include "http_log.h"
#include "http_main.h"
#include "util_script.h"
#include "util_date.h"
int temp_dssi(request_rec *r, char *args)
{
const char *s;
s = ap_table_get(r->subprocess_env,"QUERY_STRING");
if(s && *s)
ap_rprintf(r,"%s\n",s);
if(args && *args)
ap_rprintf(r,"%s\n",args);
return OK;
}
Compiling:
$ gcc -c -I/apache_root_dir/include -O2 temp_dssi.c
$ gcc -I/apache_root_dir/include -O2 temp_dssi.o -shared -o temp_dssi.so
$ cp temp_dssi.so /apache_root_dir/libexec/
httpd.conf:
LoadDSSI libexec/temp_dssi.so
temp_dssi.shtml:
<html><body><pre>
<!--#exec func="temp_dssi $DOCUMENT_ROOT" -->
</pre></body></html>
DSSI is just tested in the UNIX Platform. If you are using the others, let me know the problem.